using System;
using System.Collections.Generic;
using System.Text;
using Objects;

namespace DAL
{
    public class DALMauThe
    {
        public List<MauThe> GetAllItem()
        {
            List<MauThe> ListMauThe = new List<MauThe>();

            clsDataAccess acc = new clsDataAccess();

            string[] sname = new string[] { "@Status"};
            string[] vname = new string[] {Common.Myconst.HOATDONG.ToString() };

            System.Data.DataSet ds = acc.CommandSelect("MauThe_GetAllItem", sname, vname);

            MauThe Item = new MauThe();

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                System.Data.DataRow dr = ds.Tables[0].Rows[i];
                ListMauThe.Add((Item.Populate(dr)));
            }
            return ListMauThe;
        }

        public List<MauThe> GetByIdChuDe(int IdChuDe)
        {
            List<MauThe> ListMauThe = new List<MauThe>();

            clsDataAccess acc = new clsDataAccess();

            string[] sname = new string[] { "@Status", "@IdChuDe" };
            string[] vname = new string[] { Common.Myconst.HOATDONG.ToString(), IdChuDe .ToString()};
            System.Data.DataSet ds = acc.CommandSelect("MauThe_GetbyIdChuDe", sname, vname);

            MauThe Item = new MauThe();

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                System.Data.DataRow dr = ds.Tables[0].Rows[i];
                ListMauThe.Add((Item.Populate(dr)));
            }

            return ListMauThe;
        }

        public MauThe GetById(int Id)
        {
            MauThe Item = new MauThe();
            clsDataAccess acc = new clsDataAccess();

            string[] sname = new string[] {"@Id" };
            string[] vname = new string[] { Id.ToString() };
            System.Data.DataSet ds = acc.CommandSelect("MauThe_GetbyId", sname, vname);

            System.Data.DataRow dr = ds.Tables[0].Rows[0];
            return Item.Populate(dr);
        }


            public int Insert_MauThe(int IdChuDe,String TenMauThe, String DuongDan,String GhiChu, int Status, int SapXep)
        {
            clsDataAccess acc = new clsDataAccess();

            string[] sname = new string[] { "@IdChuDe","@TenMauThe", "@DuongDan", "@GhiChu","@Status", "@SapXep" };
            string[] vname = new string[] { IdChuDe.ToString(), TenMauThe.ToString(), DuongDan.ToString(),GhiChu.ToString(), Status.ToString(), SapXep.ToString() };
            return acc.InsertUpdateDetete("MauThe_Insert", sname, vname);

        }

        public int Update_MauThe(int id, int IdChuDe, String TenMauThe, String DuongDan, String GhiChu, int Status, int SapXep)
        {
            clsDataAccess acc = new clsDataAccess();

            string[] sname = new string[] { "@Id", "@IdChuDe", "@TenMauThe", "@DuongDan", "@GhiChu", "@Status", "@SapXep" };
            string[] vname = new string[] { id.ToString(), IdChuDe.ToString(), TenMauThe.ToString(), DuongDan.ToString(), GhiChu.ToString(), Status.ToString(), SapXep.ToString() };
            return acc.InsertUpdateDetete("MauThe_Update", sname, vname);

        }

        public int Delete_MauThe(int id)
        {
            clsDataAccess acc = new clsDataAccess();

            string[] sname = new string[] { "@id" };
            string[] vname = new string[] { id.ToString() };
            return acc.InsertUpdateDetete("MauThe_Delete", sname, vname);

        }
    }
}
